home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Ham⁄GPS / SoftKiss.src.1.8 Folder / SoftKiss.src.1.8.sit / SoftKiss.src.1.8 / lib / sfk_os_preserve.c < prev    next >
Text File  |  1992-06-25  |  1KB  |  68 lines

  1. /*
  2.  * get/save resource manager state
  3.  * by Aaron Wohl / N3LIW (aw0g+@andrew.cmu.edu) jul 1990
  4.  * 6393 Penn Ave #303
  5.  * Pittsburgh PA, 15206
  6.  * work: (412)-268-5032
  7.  * home: (412)-731-6159
  8.  */
  9.  
  10. #define NO_OSP_DEF
  11. #include "sfk_os_preserve.h"
  12.  
  13. /*
  14.  * call a routine possibly switching to the system heap
  15.  * take up to 4 arguments which are passed to the routine
  16.  * to call.
  17.  * The reserr proc in low memory is replaces so that if passed
  18.  * function gets a resource error it won't call the installed
  19.  * reserr procedure.
  20.  */
  21. long OSP_protected_call(
  22.     int new_heap,
  23.     long (*cproc)(long a1,
  24.         long a2,
  25.         long a3,
  26.         long a4),
  27.     long a1,
  28.     long a2,
  29.     long a3,
  30.     long a4);
  31. long OSP_protected_call(
  32.     int new_heap,
  33.     long (*cproc)(long a1,
  34.         long a2,
  35.         long a3,
  36.         long a4),
  37.     long a1,
  38.     long a2,
  39.     long a3,
  40.     long a4)
  41. {
  42.     THz oldZone;
  43.     long result;
  44.     ProcPtr old_res_err=ResErrProc;
  45.     int old_err_num=ResErr;
  46.     int old_load;
  47.     asm {
  48.         bra.s @skip_rts
  49.     new_err_proc:
  50.         rts
  51.     skip_rts:
  52.         lea @new_err_proc,a0
  53.         move.l a0,ResErrProc
  54.     }
  55.     oldZone = GetZone();
  56.     if((new_heap&OSP_sys)!=0)
  57.         SetZone(SystemZone());
  58.     old_load=ResLoad;
  59.     SetResLoad(((new_heap&OSP_noload)==0));
  60.     result=(*cproc)(a1,a2,a3,a4);
  61.     SetResLoad(old_load);
  62.     if((new_heap&OSP_sys)!=0)
  63.         SetZone(oldZone);
  64.     ResErrProc=old_res_err;
  65.     ResErr=old_err_num;
  66.     return result;
  67. }
  68.